// import menuList from '@/assets/js/menu.js'
let isUndefined = Val => {
  return Val === undefined || Val === null;
};
export default {
  state: {
    reloadTable: false,
    allMenu: {
      list: [],
      active: 0
    },
    sideMenu: {
      list: [],
      active: {
        second: -1,
        third: -1
      }
    },
    forthMenu: {
      list: [],
      active: -1
    },
    activeMenu: {
      first: 0,
      second: -1,
      third: -1,
      forth: -1,
      info: {}
    }
  },

  mutations: {
    setReloadTable(state) {
      state.reloadTable = !state.reloadTable;
    },

    setActiveMenuFn(state, payload) {
      if (payload === null) {
        state.activeMenu = payload;
        return;
      }
      let index = payload.index;
      state.activeMenu.first = isUndefined(index[0]) ? -1 : index[0];
      state.activeMenu.second = isUndefined(index[1]) ? -1 : index[1];
      state.activeMenu.third = isUndefined(index[2]) ? -1 : index[2];
      state.activeMenu.forth = isUndefined(index[3]) ? -1 : index[3];
      state.activeMenu.info = payload.info || {};
    },

    setAllMenuFn(state, payload) {
      if (!isUndefined(payload.list)) {
        state.allMenu.list = payload.list;
      }
      if (!isUndefined(payload.active)) {
        state.allMenu.active = payload.active;
      }
    },

    setSideMenuFn(state, payload) {
      if (!isUndefined(payload.list)) {
        state.sideMenu.list = payload.list;
      }
      if (!isUndefined(payload.active)) {
        state.sideMenu.active = payload.active;
      }
    },

    setForthMenuFn(state, payload) {
      if (!isUndefined(payload.list)) {
        state.forthMenu.list = payload.list;
      }
      if (!isUndefined(payload.active)) {
        state.forthMenu.active = payload.active;
      }
    }
  },

  actions: {}
};
